
#ifndef __XB_CPU_ACCESS_H__
#define __XB_CPU_ACCESS_H__

/* ------------------------------------------------------------------------- */

#define in_byte(port)			(uint8)io_read((port), 1)
#define in_word(port)			(uint16)io_read((port), 2)
#define in_dword(port)			io_read((port), 4)
#define out_byte(port, val)		io_write((port), (val), 1)
#define out_word(port, val)		io_write((port), (val), 2)
#define out_dword(port, val)	io_write((port), (val), 4)

/* ------------------------------------------------------------------------- */

capi void fastcall check_eflags_access(void);
capi void fastcall check_cr_access(int cr_no);
capi void fastcall check_dr_access(int dr_no);
capi void fastcall check_msr_access(uint32 addr);
capi void fastcall check_lxdt_access(void);
capi void fastcall check_ltr_access(uint16 sel, uint64 desc);
capi void fastcall check_port_access(void);
capi void fastcall check_tsc_access(void);
capi void fastcall check_if_access(void);

capi void fastcall check_cs_access(uint16 seg, uint64 xseg, uint16 sel, uint64 desc);
capi void fastcall check_ss_access(uint16 seg, uint64 xseg, uint16 sel, uint64 desc);
capi void fastcall check_ds_access(uint16 seg, uint64 xseg, uint16 sel, uint64 desc);

capi uint32 fastcall virtual_execute(uint16 sel, uint64 desc, uint32 va, size_t size);
capi uint32 fastcall virtual_read(uint16 sel, uint64 desc, uint32 va, size_t size);
capi void fastcall virtual_write(uint16 sel, uint64 desc, uint32 va, uint32 data, size_t size);

capi uint32 fastcall paging(uint32 la);

/* ------------------------------------------------------------------------- */

#endif
